package com.naire.modul.answer.action;

import java.util.ArrayList;
import java.util.List;

import net.common.action.GeneralAction;

import com.naire.modul.answer.service.AnswerDeleteService;
import com.naire.modul.answer.service.AnswerEditorService;
import com.naire.modul.answer.service.AnswerFindService;
import com.naire.modul.answer.service.AnswerSearchAllService;
import com.naire.modul.answer.service.AnswerSearchService;
import com.naire.modul.answer.vo.AnswerVo;

public class AnswerAction extends GeneralAction {

	private static final long serialVersionUID = 7127573666355745443L;

	private AnswerVo bean = new AnswerVo();
	private List<AnswerVo> list = new ArrayList<AnswerVo>();
	private String parent_code;

	public String search() throws Exception {
		AnswerSearchService service = new AnswerSearchService();
		service.setPageBean(pageBean);
		service.setParent_code(parent_code);
		service.invoke();
		list = service.getList();
		return SUCCESS;
	}
	
	public String searchAll() throws Exception {
		AnswerSearchAllService service = new AnswerSearchAllService();
		service.setPageBean(pageBean);
		service.setParent_code(parent_code);
		service.invoke();
		list = service.getList();
		return SUCCESS;
	}

	public String editor() throws Exception {
		AnswerEditorService service = new AnswerEditorService();
		service.setBean(bean);
		service.setParent_code(parent_code);
		service.invoke();
		return SUCCESS;
	}

	public String find() throws Exception {
		if (bean.getAnswer_id() != null) {
			AnswerFindService service = new AnswerFindService();
			service.setId(bean.getAnswer_id());
			service.invoke();
			bean = service.getBean();
		}
		return SUCCESS;
	}

	public String delete() throws Exception {
		AnswerDeleteService service = new AnswerDeleteService();
		service.setBean(bean);
		service.invoke();
		return SUCCESS;
	}

	public AnswerVo getBean() {
		return bean;
	}

	public void setBean(AnswerVo bean) {
		this.bean = bean;
	}

	public List<AnswerVo> getList() {
		return list;
	}

	public void setList(List<AnswerVo> list) {
		this.list = list;
	}

	public String getParent_code() {
		return parent_code;
	}

	public void setParent_code(String parent_code) {
		this.parent_code = parent_code;
	}
}
